import 'package:flutter/material.dart';
import 'package:flutter_video/task/slider.dart';
import 'package:fluttertoast/fluttertoast.dart';

class MinePage extends StatefulWidget {
  @override
  State<StatefulWidget> createState() {
    return _MinePageState();
  }
}

class _MinePageState extends State<MinePage> {
  double _duration = 100.0;
  double _currentPos = 10.0;
  double _bufferPos = 0.0;

  static MyFijkSliderColors sliderColors = MyFijkSliderColors(
      cursorColor: Color.fromARGB(240, 255, 255, 255),
      playedColor: Color.fromARGB(200, 33, 150, 243),
      baselineColor: Color.fromARGB(100, 20, 20, 20),
      bufferedColor: Color.fromARGB(180, 200, 200, 200));

  @override
  void initState() {
    super.initState();
  }

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
        home: GestureDetector(
      onHorizontalDragStart: (DragStartDetails details) {
        print("onHorizontalDragStart:$_duration");
      },
      onHorizontalDragUpdate: (DragUpdateDetails details) {
        print("onHorizontalDragUpdate:$_duration");
      },
      child: Container(
        color: Colors.yellow,
        child: MyFijkSlider(
          colors: sliderColors,
          value: _currentPos,
          cacheValue: _bufferPos,
          min: 0.0,
          max: _duration,
          onChanged: (v) {
            setState(() {
              _currentPos = v;
            });
          },
          onChangeEnd: (v) {
            //Fluttertoast.showToast(msg: "onChangeEnd");
            setState(() {
              _currentPos = v;
            });
          },
        ),
      ),
    ));
  }
}
